Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for source links on GitHub enterprise instances #843

Merged
merged 5 commits into from
Oct 26, 2018

Conversation

tomratcliffe
Copy link
Contributor

This adds support for GitHub Enterprise source URLs found in the list of git ls-remote --get-url.

The updated regex checks for URLs like github.acme.com instead of just github.com, and then uses the matched hostname when generating the source URLs.

I didn't add any tests for this as I'm not sure what your testing strategy is/I couldn't find a testing file for just this module. Happy to try and add this in though if required!

Should be backwards compatible with old URLs.

Fixes #249, which was closed in favour of #129.

This doesn't entirely solve #129, but closes the gap on allowing GHE to work out of the box.

Copy link
Collaborator

@aciccarello aciccarello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I'd like to find some way to unit test this.

@tomratcliffe
Copy link
Contributor Author

tomratcliffe commented Aug 23, 2018

I had a look at writing some tests, and can get one that would test that it defaults to github.com, but I can't work out how to stub out the internal ShellJS module and make it return whatever I want (so I could fake having a certain remote on a git repo):

import * as github from './../lib/converter/plugins/GitHubPlugin';
import Assert = require('assert');

describe('GitHubRepository', function() {
    let repository = new github.Repository('', '');

    describe('contructor', function() {
        it('must default to github.com hostname', function() {
            Assert.equal(repository.gitHubHostname, 'github.com');
        });
    });
});

Any ideas @aciccarello ?

Tom Ratcliffe added 3 commits August 23, 2018 20:12
Needed for better unit testing
Allows us to more easily unit test the class by passing in an array of strings
@tomratcliffe
Copy link
Contributor Author

I figured it out, with a small refactor. Should be good to go @aciccarello!

@tomratcliffe
Copy link
Contributor Author

@aciccarello Any thoughts on this? Thanks!

@aciccarello
Copy link
Collaborator

Sorry for not following up on this @tomratcliffe. I'm hoping to look at it this week.

@aciccarello aciccarello merged commit 02d2882 into TypeStrong:master Oct 26, 2018
@aciccarello
Copy link
Collaborator

Thanks for your contribution @tomratcliffe!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate links to the source codes on GitHub Enterprise
2 participants